<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('定时上传记录')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>IMEI号：</label>
                                <input type="text" name="deviceImei"/>
                            </li>
                            <li>
                                <label>表号：</label>
                                <input type="text" name="meterNo"/>
                            </li>
                            <li class="select-time">
                                <label>上传时间： </label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" th:value="${startDate}" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" th:value="${endDate}" name="params[endTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="record:reading:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "record/reading";

        $(function() {
            var options = {
                url: prefix + "/list",
                exportUrl: prefix + "/export",
                sortName: "readingTime",
                sortOrder: "desc",
                pageSize: 15,
                pageList: [30, 50, 100, 200],
                sidePagination: 'client',
                modalName: "定时上传记录",
                columns: [
                {
                    field: 'deviceImei',
                    title: 'IMEI号',
                    sortable: true
                },
                {
                    field: 'meterNo',
                    title: '表号',
                    sortable: true
                },
                {
                    field: 'result',
                    title: '累计用量',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'result1',
                    title: '尖段用量',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'result2',
                    title: '峰段用量',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'result3',
                    title: '平段用量',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'result4',
                    title: '谷段用量',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'result5',
                    title: '深谷段用量',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return parseFloat(value).toFixed(2);
                    }
                },
                {
                    field: 'csq',
                    title: '信号值',
                    sortable: true,
                    formatter: function(value, row, index) {
                        if(value >= 26 && value <= 31){
                            return '<img width="20px;" height="20px;" src="/img/signal_5.jpg">';
                        } else if(value >= 21 && value <= 25) {
                            return '<img width="20px;" height="20px;" src="/img/signal_4.jpg">';
                        } else if(value >= 17 && value <= 20) {
                            return '<img width="20px;" height="20px;" src="/img/signal_3.jpg">';
                        } else if(value >= 13 && value <= 16) {
                            return '<img width="20px;" height="20px;" src="/img/signal_2.jpg">';
                        } else if(value >= 9 && value <= 12) {
                            return '<img width="20px;" height="20px;" src="/img/signal_1.jpg">';
                        } else {
                            return '<img width="20px;" height="20px;" src="/img/signal_0.jpg">';
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '上传时间',
                    sortable: true
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>